<template>
    <!-- 引入container布局 -->
    <el-container class="home-container">
        <!-- 头部 -->
        <el-header>
            <div class="div1">
                <img src="../assets/img/logo.png" alt="i" class="img1">
                <span class="span1" >后台管理系统</span>
            </div>
            <!-- 退出按钮 -->
            <el-button class="logout" type="danger" icon="iconfont icon-tuichu" circle @click="logout()"></el-button>          
        </el-header>
        <!-- 主体 -->
        <el-container>
            <!-- 侧边栏 unique-opened:-->
            <el-aside width="200px"  >
                <el-menu background-color="#606266" text-color="#FFFFFF" 
                active-text-color="#409EFF" :router="true" 
                default-active="/home" >
                        <!-- 首页 -->
                        <div class="home-button" @click="return_home()">
                            <i class="el-icon-s-home"></i>
                            <span> 首页</span>
                        </div>
                        <!-- 用户管理菜单 -->
                        <el-submenu index="1" >
                            <template slot="title">
                                <i class="iconfont icon-yonghu"></i>
                                <span>用户管理</span>
                            </template>
                            <!-- 用户列表 -->
                            <el-menu-item index="user">
                                <template slot="title">
                                    <i class="el-icon-s-flag"></i>
                                    <span>用户列表</span>
                                </template>
                            </el-menu-item>                             
                        </el-submenu>
                        <!-- 管理员管理菜单 -->
                        <el-submenu index="2">
                            <template slot="title">
                            <i class="iconfont icon-yonghu"></i>
                            <span>管理员</span>
                            </template>
                            <!-- 管理员列表 -->
                            <el-menu-item index="admin">
                                <template slot="title">
                                    <i class="el-icon-s-flag"></i>
                                    <span>管理员列表</span>
                                </template>
                            </el-menu-item>                             
                        </el-submenu>
                        <!-- 评论管理菜单 -->
                        <el-submenu index="3">
                            <template slot="title">
                            <i class="el-icon-s-comment"></i>
                            <span>评论管理</span>
                            </template>
                            <!-- 评论列表 -->
                            <el-menu-item index="checked">
                                <template slot="title">
                                    <i class="el-icon-circle-check"></i>
                                    <span>已审核评论</span>
                                </template>
                            </el-menu-item>  
                            <el-menu-item index="unchecked">
                                <template slot="title">
                                    <i class="el-icon-circle-close"></i>
                                    <span>未审核评论</span>
                                </template>  
                            </el-menu-item>                          
                        </el-submenu>
                    </el-menu>
            </el-aside>
            <!-- 主体内容 -->
            <el-main>
                <router-view></router-view>
            </el-main>
        </el-container>
        </el-container>
</template>

<script>
export default {
    data(){
        return{
         
        }
    },
    
    //onload
    created(){
        //执行token验证
        
    },
    methods:{
        //安全退出
        logout() {
        this.$confirm('是否退出登录?', '提示', {
          confirmButtonText: '退出',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          //清除session
          window.sessionStorage.clear();
          //回到登录页面
          this.$router.push("/login");
          //提示退出成功
          this.$message({
            type: 'success',
            message: '退出成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '取消退出'
          });          
        });
      },
      //回到欢迎界面
      return_home(){
          this.$router.push("/hello");
          this.$message.success('欢迎');
      },
    }
}
</script>


<style>
/* container布局 */
.home-container{
    height: 100%;
}
/* 头部 */
.el-header{
    background-color: #373d41;
    display: flex;
    align-items: center;
    /* 左右贴边 */
    justify-content: space-between;
    /* 左边界 */
    padding-left: 0%;
    padding-right: 0%;    
}
/* div */
.div1{
    display: flex;
    align-items: center;
}
/* span */
.span1{
    display: flex;
    align-items: center;
    color: #fff;
    font-size: 25px;
    margin-left: 25px;
}
/* img */
.img1{
    display: flex;
    align-items: center;
    width: 200px;
    height: 55px;
}
/* logout */
.logout{
    display: flex;
    align-items: center;
    /* margin-left: 100px; */
    width:50px;
    height: 50px;
}

/* 侧边栏 */
.el-aside {
    background-color: #909399;
    align-content: center;
    
}

/* 主体 */
.el-main {
    background-color:rgb(228, 238, 235);
}

/* 首页按钮样式 */
.home-button{
    background-color: #606266;
    font-size: 15px;
    line-height: 50px;
    color: #fff;
    margin-left: 30px;
    letter-spacing: 0.2em;
    /* 显示小手 */
    cursor: pointer;
}



</style>